﻿<?php
    @session_start();
    include("template/head.php");
	
	
	$sql = "SELECT * FROM `st_attr_sortie` WHERE id_article =".$_GET["id_article"];;
	$obj = new Mysql ();
	$result = mysql_query($sql);

    //selectionner la réference et la photo de l'article 
    $s = "select * from st_article where id_article=".$_GET["id_article"];
    $r = mysql_query($s);
    while ($d=mysql_fetch_array($r)) {
        $REFARICLE=$d["ref_article"];
        $PHOTOARTICLE=$d["photo_name"];
        $DESIGNATION=$d["designation"];
        $price=$d["prix"];
		
    }
?>
<style type="text/css">
    #example_filter label input{
        height: 27px;
    }
</style>

    <div class="container-fluid">
        <div class="row-fluid">
                
        <?php include("template/menu_left.php") ;
		
                if ((isset($_GET["action"])) && ($_GET["action"] == "deleted"))
                {
                echo'
                <div class="alert alert-success span8">
                    Le sortie de stock est supprimer avec succès <button type="button" class="close" data-dismiss="alert">&times;</button>
                </div>
                ';
                }
				if ((isset($_GET["action"])) && ($_GET["action"] == "added"))
                {
                echo'
                <div class="alert alert-success span8">
                    Le sortie de stock est enregistrée avec succès <button type="button" class="close" data-dismiss="alert">&times;</button>
                </div>
                ';
                }
                if ((isset($_GET["action"])) && ($_GET["action"] == "updated"))
                {
                echo'
                <div class="alert alert-success span8">
                    Mise à jour de sortie de stock est effectuée avec succès. <button type="button" class="close" data-dismiss="alert">&times;</button>
                </div>
                ';
                }
				if ((isset($_GET["action"])) && ($_GET["action"] == "addedError"))
                {
                echo'
                <div class="alert alert-danger span8">
                    Le sortie de stock n\'est pas enregistrer. ressayer plus tard. <button type="button" class="close" data-dismiss="alert">&times;</button>
                </div>
                ';
                }

            ?> 
        <div class="span10" id="content">
            <div class="row-fluid">
            <!-- block -->
            <div class="block">
              <div class="navbar navbar-inner block-header">
                <div class="muted pull-left span12">
                	<div class="span9">
             			<h5><?php echo 'Article : '.$REFARICLE.' <span style="margin:0 5px 0 5px;"><br></span> Designation : '.$DESIGNATION  ?></h5>
                	</div>
                	<div class="span3">
                		<a class="btn btn-primary btn-sm" href="add_sortie.php?page=list_sortie" style="float:right;width:200px;margin-bottom:10px;" >Ajouter une opération de vente</a>
                	</div>
                </div>
              </div>
              <div class="block-content collapse in">
                <div class="span12">
                    <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="example">
                    <thead>
                      <tr>
                        <th>Qté Vendue</th>
                        <th>Unité de vente</th>
        				        <th>Référence</th>
        				        <th>Prix de vente</th>
        				        <th>Date opération</th>
        				        <th></th>
                      </tr>
                    </thead>
                    <tbody>
                       <?php  while($row = mysql_fetch_object($result)){?>
                       	        
                      	<tr class="odd gradeX">
                        <td style="color:#d0343a;text-align:center;"><?php echo number_format($row->Qte, 0, '', ' ')?></td>
                        <td>
                          <?php 
                            $table = "SELECT DISTINCT `raison_social`, `id_unite` FROM st_att_unite where id_unite = ".$row->id_unite;     
                            //echo $table;
                            $colonne = mysql_query($table);     
                            while($data = mysql_fetch_array($colonne)){
                              echo $data['raison_social'];    
                            } 
                          
                          ?>

                        </td>
				        <td><?php echo getRefArticle($row->id_article)?></td>
						<td><?php echo number_format($price, 3, '.', ' ')?></td>
						<td><?php echo $row->Date_cmd?></td>
						<td>
							<?php 
							$sqls = "SELECT * FROM `st_attr_sortie` WHERE id_sortie=".$row->id_sortie;
							$obj = new Mysql ();
							$results = mysql_query($sqls);
							$rows = mysql_fetch_object($results);
							?>
							<a href="#<?php echo $row->id_sortie?>myModal" data-toggle="modal" class="btn btn btn-small" style="margin-right:20px;">Consultation</a>
							
            					
            					<div id="<?php echo $row->id_sortie?>myModal" class="modal hide">
                                <div class="modal-header">
                                   <button data-dismiss="modal" class="close" type="button">&times;</button>
                                	   <h4>Consultation article : <?php echo getRefArticle($rows->id_article); ?></h4>
                                   </div>
                                   <div class="modal-body">
                                       <p><strong>Désignation : </strong><?php echo nl2br(getDesignation($rows->id_article)); ?></p>
                                       <p><strong>Unité de stockage : </strong><?php echo getUnitArticle($rows->id_article) ?></p>
                                       <p><strong>Observation : </strong><?php echo nl2br($rows->note); ?></p>
                                   </div>
                               </div>
                               
							<a class="btn btn-primary btn-small" href="edit_sortie.php?action=update&page=list_sortie&id_sortie=<?php echo $row->id_sortie?>"><i class="icon-pencil icon-white"></i></a>
						   
						    <a data-placement="bottom" data-toggle="modal" href="#<?php echo $row->id_sortie?>myModalsuppr" class="btn btn-danger btn-small"><i class="icon-remove icon-white"></i></a>  
				        	
				        	<div id="<?php echo $row->id_sortie ?>myModalsuppr" class="modal hide">
								<div class="modal-header">
									<button data-dismiss="modal" class="close" type="button">&times;</button>
										<p>Voulez-vous supprimer la vente relative à l'article : <?php echo $REFARICLE; ?> </p>
									</div>
								
									<div class="modal-footer">
										<a class="btn btn-primary" href="submit/sortie/delete_sortie.php?action=delete&id_sortie=<?php echo $row->id_sortie?>&id_article=<?php echo $rows->id_article?>&qt=<?php echo $row->Qte?>">Confirmer</a>
										<a data-dismiss="modal" class="btn" href="#">Annuler</a>
									</div>
							</div>
				        </td>
                      </tr>
                      <?php
                        }
                      ?>
                    </tbody>
                  </table>
                </div>
                <a class="btn btn-primary btn-sm" href="add_sortie.php?page=list_sortie" style="float:right;width:200px;margin:20px;" >Ajouter  une opération de vente</a>
              </div>
            </div>
        <!-- /block -->
          </div>
                </div>
            </div>
            <hr>
        </div>
<?php  include("template/footer.php") ; ?>